package com.bbs.service.impl;

import com.bbs.domain.User;

import com.bbs.mapper.UserMapper;
import com.bbs.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.util.List;

@Service
public class LoginServiceImpl implements LoginService {
    @Autowired
    private UserMapper userMapper;

    /**
     * 用户登录
     * @param username
     * @param password
     * @return
     */
    @Override
    public User login(String username, String password) {
        User loginUser =new User();
        loginUser.setUsername(username);
        loginUser.setUserpass(password);
        List<User> userList = userMapper.select(loginUser);
        return userList.get(0);

    }

    @Override
    public void changeStatus(User user) {
        if (user!=null){
            user.setLoginstatus(1);
            userMapper.updateByPrimaryKey(user);
        }
    }
}
